package com.entfrm.system.controller;

import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.entfrm.base.api.R;
import com.entfrm.system.entity.BiHbtz;
import com.entfrm.system.entity.EndInfo;
import com.entfrm.system.service.BiHbtzService;
import com.entfrm.system.service.EndInfoService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author entfrm
 * @date 2020-04-23 18:15:10
 * @description 应用Controller
 */
@RestController
@AllArgsConstructor
@RequestMapping("/sell")
public class SellController {

    private final EndInfoService endInfoService;
    private QueryWrapper<EndInfo> getQueryWrapper(EndInfo endInfo) {
        return new QueryWrapper<EndInfo>()
                .eq(StrUtil.isNotBlank(endInfo.getAutoId()+""), "autoId", endInfo.getAutoId());
    }


    @GetMapping("/getEndInfo")
    public R list(Page page, EndInfo endInfo) {
        IPage<EndInfo> biHbtzPage = endInfoService.page(page, getQueryWrapper(endInfo));
        return R.ok(biHbtzPage.getRecords(), biHbtzPage.getTotal());
    }
    
}
